package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.entity.GeConParty;
import com.htgd.gardenexpo.dao.GeConPartyDao;
import com.htgd.gardenexpo.entity.PageQuery;
import com.htgd.gardenexpo.service.GeConPartyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 党政信息表(GeConParty)表服务实现类
 *
 * @author makejava
 * @since 2021-06-08 17:21:32
 */
@Service("geConPartyService")
public class GeConPartyServiceImpl implements GeConPartyService {
    @Resource
    private GeConPartyDao geConPartyDao;

    /**
     * 通过ID查询单条数据
     *
     * @param partyId 主键
     * @return 实例对象
     */
    @Override
    public GeConParty queryById(Integer partyId) {
        return this.geConPartyDao.queryById(partyId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GeConParty> queryAllByLimit(int offset, int limit) {
        return this.geConPartyDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<GeConParty> getAllHomeParty() {
        return this.geConPartyDao.getAllHomeParty();
    }
    @Override
    public List<GeConParty> getAllPartyByValue(PageQuery pageQuery) {
        return this.geConPartyDao.getAllPartyByValue(pageQuery);
    }
    @Override
    public List<GeConParty> getAllPartyByValueNoContent(PageQuery pageQuery) {
        return this.geConPartyDao.getAllPartyByValueNoContent(pageQuery);
    }

    /**
     * 新增数据
     *
     * @param geConParty 实例对象
     * @return 实例对象
     */
    @Override
    public GeConParty insert(GeConParty geConParty) {
        this.geConPartyDao.insert(geConParty);
        return geConParty;
    }

    /**
     * 修改数据
     *
     * @param geConParty 实例对象
     * @return 实例对象
     */
    @Override
    public GeConParty update(GeConParty geConParty) {
        this.geConPartyDao.update(geConParty);
        return this.queryById(geConParty.getPartyId());
    }

    /**
     * 通过主键删除数据
     *
     * @param partyId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer partyId) {
        return this.geConPartyDao.deleteById(partyId) > 0;
    }
}
